/**
 * 模板字符串
 */
console.log('模板字符串');


console.log(`string text line 1
string text line 2`);
// "string text line 1
// string text line 2"


const a1 = 5;
const b1 = 10;
console.log(`Fifteen is ${a1 + b1} and
not ${2 * a1 + b1}.`);
// "Fifteen is 15 and
// not 20."


function fn() {
    return "Bob";
}
console.log(`Hi ${fn()}!`);
// "Hi Bob!"


// 标签模板
const person = "Mike";
const age = 28;

function myTag(strings, personExp, ageExp) {
    const str0 = strings[0]; // "That "
    const str1 = strings[1]; // " is a "
    const str2 = strings[2]; // "."

    const ageStr = ageExp > 99 ? "centenarian" : "youngster";

    // 我们甚至可以返回使用模板字面量构建的字符串
    return `${str0}${personExp}${str1}${ageStr}${str2}`;
}

const output = myTag`That ${person} is a ${age}.`;

console.log(output);
// That Mike is a youngster.

console.log`Hello`; // [ 'Hello' ]
console.log.bind(1, 2)`Hello`; // 2 [ 'Hello' ]
new Function("console.log(arguments)")`Hello`; // [Arguments] { '0': [ 'Hello' ] }

function recursive(strings, ...values) {
    console.log(strings, values);
    return recursive;
}
recursive`Hello``World`;
// [ 'Hello' ] []
// [ 'World' ] []


